class Solution {
public:
    int lengthOfLongestSubstring(string s) {
        int left = 0, right = 0;
        int len = 0, n = s.size();
        //unordered_map<char, int> count;
        int count[128] = { 0 };

        while (right < n)
        {
            count[s[right]]++;
            while (count[s[right]] > 1)
                count[s[left++]]--;

            len = max(len, right - left + 1);
            right++;
        }

        return len;
    }
};